package com.moli.iov.handle.alarm.biz;

import com.moli.iov.handle.alarm.biz.real.GeneralAlarmReal;
import com.moli.iov.handle.alarm.biz.real.MalfunctionReal;
import com.moli.iov.handle.alarm.biz.real.PlatformJudgmentReal;
import com.moli.iov.handle.alarm.model.dto.AuthDto;
import com.moli.iov.handle.alarm.service.IAlarmOtherService;
import com.moli.iov.protocol.model.realtime.RealTimeInfoReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <p>
 *  实时报警
 * </p>
 *
 * @author: zql
 * @Date: 2019/2/14 11:42
 */
@Slf4j
@Component("realHandler")
public class RealHandler {

    @Autowired
    private GeneralAlarmReal generalAlarmReal;

    @Autowired
    private MalfunctionReal malfunctionReal;

    @Autowired
    private PlatformJudgmentReal platformJudgmentReal;

    @Autowired
    private IAlarmOtherService alarmOtherService;

    /**
     * 实时上报报警处理
     * @param realTimeInfoReq  实时报文
     */
    public void handle(RealTimeInfoReq realTimeInfoReq) {

        AuthDto authDto = alarmOtherService.isAuthorized(realTimeInfoReq.vin);

        //普通报警
        generalAlarmReal.handle(realTimeInfoReq, authDto);

        //故障处理
        malfunctionReal.handle(realTimeInfoReq, authDto);

        //平台判断
        platformJudgmentReal.handle(realTimeInfoReq, authDto);
    }
}
